package com.hzit.controller;

import com.hzit.service.IUserService;
import com.hzit.util.R;
import com.hzit.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wf
 * @since 2024-03-01
 */
@RestController
@RequestMapping("/user")
public class UserController {

	@Autowired
	private IUserService userService;

	//1. 列表用户
	@GetMapping("/list")
	@PreAuthorize("hasAuthority('student:tolist')")
	public R list(){
		return R.ok(userService.list());
	}

	//2. 用户登录
	@PostMapping("/login")
	public R login(@RequestBody UserVo vo){
		Map map = userService.login(vo);
		return R.ok(map);
	}
}
